package com.punai.dataanalysis.cblib.constants;

import com.punai.dataanalysis.cblib.bo.MMAInfo;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class CbLibConstants {

    public enum PriceCompareType{
        SSPJJ("算术平均价","avgPrice",true,"平均价"),
        ZGJ("最高价","maxPrice",false,""),
        ZDJ("最低价","minPrice",false,""),
        JGPC("价格偏差","deviationPrice",true,"价格偏差")
        ;

        private String label;
        private String prop;
        /**
         * 是否项目对比
         */
        private boolean isXBDB;

        /**
         * 项目对比名称
         */
        private String xmdbLabel;

        PriceCompareType(String label,String prop,boolean isXBDB,String xmdbLabel) {
            this.label = label;
            this.prop = prop;
            this.isXBDB = isXBDB;
            this.xmdbLabel = xmdbLabel;
        }

        public String getLabel() {
            return label;
        }

        public void setLabel(String label) {
            this.label = label;
        }

        public String getProp() {
            return prop;
        }

        public void setProp(String prop) {
            this.prop = prop;
        }

        public BigDecimal getValue(MMAInfo mmaInfo) {
            switch (this) {
                case SSPJJ:
                    return mmaInfo.getAvgPrice();
                case ZGJ:
                    return mmaInfo.getMaxPrice();
                case ZDJ:
                    return mmaInfo.getMinPrice();
                case JGPC:
                    return mmaInfo.getDeviationPrice();
                default:
                    return BigDecimal.ZERO;
            }
        }

        public static List<PriceCompareType> getXMDBTab() {
            List<PriceCompareType> result = new ArrayList<>();
            for (PriceCompareType value : values()) {
                if (value.isXBDB) {
                    result.add(value);
                }
            }
            return result;
        }
    }

}
